const mongoose = require('mongoose')
const Schema = mongoose.Schema
const ObjectId = Schema.ObjectId
const ArcticSchema = new Schema({
    title : {type:String}, //标题
    content : {type: String}, //文章内容
    authorId : {type: ObjectId,ref: 'Users'}, //作者id
    top: { type: Boolean, default: false}, // 置顶文章
    good: { type: Boolean, default: false }, // 精华文章
    createAt: { type: Date, default: Date.now}, //创建时间
    updateAt: { type: Date, default: Date.now }, //更新时间
    countInfo: {
      commentCount: {type: Number, default: 0}, //评论数
      visitCount: {type: Number, default: 0},  //浏览数
      collectCount: {type: Number, default: 0}, 
      likeCount: {type: Number, default: 0}  //收藏数
    },
    categoryId: { type: ObjectId, ref: 'Categorys' }, //文章分类
    thumbnail : {type:Array},  //缩略图
    state: { type: Number,enum: [0, 1], default: 1 },// 文章状态
    tags : {type:[ObjectId],ref: 'Tags'}
})

module.exports = mongoose.model('Articles', ArcticSchema)